/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jfreecharttest;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;

/**
 *
 * @author Ariel
 */
public class Main {

 private static CategoryDataset createDataset() {

        //os labels de cada linha
        final String series1 = "E_explicito_Dinamica";
        final String series2 = "E_explicito_EstaticoDCWC";
        final String series3 = "E_explicito_EstaticoEICH";
        final String series4 = "E_explicito_EstaticoEISCH";
        final String series5 = "E_explicito_EstaticoLICH";
        final String series6 = "E_explicito_EstaticoLISCH";
        final String series7 = "E_implicito_Arvore_Binaria";
        final String series8 = "E_implicito_Brent";
        final String series9 = "E_implicito_LinearQuotient";
        final String series10 = "E_implicito_Sequencial";

        // column keys... seria o packing factor
        final String carga1 = "0.1";
        final String carga2 = "0.2";
        final String carga3 = "0.3";
        final String carga4 = "0.4";
        final String carga5 = "0.5";
        final String carga6 = "0.6";
        final String carga7 = "0.7";
        final String carga8 = "0.8";

        int i1 = 1;

        // create the dataset...
        final DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        //o primeiro argumento é o valor da f(x), no nosso caso o average probe.
        dataset.addValue(1.0, series1, carga1);
        dataset.addValue(4.0, series1, carga2);
        dataset.addValue(3.0, series1, carga3);
        dataset.addValue(5.0, series1, carga4);
        dataset.addValue(5.0, series1, carga5);
        dataset.addValue(7.0, series1, carga6);
        dataset.addValue(0.0, series1, carga7);
        dataset.addValue(0.0, series1, carga8);

        dataset.addValue(5.0, series2, carga1);
        dataset.addValue(7.0, series2, carga2);
        dataset.addValue(6.0, series2, carga3);
        dataset.addValue(8.0, series2, carga4);
        dataset.addValue(4.0, series2, carga5);
        dataset.addValue(4.0, series2, carga6);
        dataset.addValue(2.0, series2, carga7);
        dataset.addValue(1.0, series2, carga8);

        dataset.addValue(4.0, series3, carga1);
        dataset.addValue(3.0, series3, carga2);
        dataset.addValue(2.0, series3, carga3);
        dataset.addValue(3.0, series3, carga4);
        dataset.addValue(6.0, series3, carga5);
        dataset.addValue(3.0, series3, carga6);
        dataset.addValue(4.0, series3, carga7);
        dataset.addValue(3.0, series3, carga8);

        dataset.addValue(0.0, series4, carga1);
        dataset.addValue(1.0, series4, carga2);
        dataset.addValue(2.0, series4, carga3);
        dataset.addValue(3.0, series4, carga4);
        dataset.addValue(4.0, series4, carga5);
        dataset.addValue(5.0, series4, carga6);
        dataset.addValue(6.0, series4, carga7);
        dataset.addValue(20.0, series4, carga8);

        dataset.addValue(0.0, series5, carga1);
        dataset.addValue(1.0, series5, carga2);
        dataset.addValue(2.0, series5, carga3);
        dataset.addValue(3.0, series5, carga4);
        dataset.addValue(4.0, series5, carga5);
        dataset.addValue(5.0, series5, carga6);
        dataset.addValue(6.0, series5, carga7);
        dataset.addValue(7.0, series5, carga8);

        dataset.addValue(2.0, series6, carga1);
        dataset.addValue(6.0, series6, carga2);
        dataset.addValue(10.0, series6, carga3);
        dataset.addValue(9.0, series6, carga4);
        dataset.addValue(8.0, series6, carga5);
        dataset.addValue(7.0, series6, carga6);
        dataset.addValue(6.0, series6, carga7);
        dataset.addValue(5.0, series6, carga8);

        //E assim por diante... se eu quiser adicionar os outros métodos
        //é só fazer analogamente p/ series7,8,9 e 10.

        return dataset;

    }
    /**
     * @param args the command line arguments
     */
public static void main(String[] args) {

//
//      Exemplo de um gráfico DataPie, se quiser ver como é, só descomente esse código e
//      passe chart como argumento do new ChartFrame() >> new ChartFrame("Nome da janela",chart)
//

/*
    // create a dataset...
    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Category 1", 43.2);
    data.setValue("Category 2", 27.9);
    data.setValue("Category 3", 79.5);
    // create a chart...
    JFreeChart chart = ChartFactory.createPieChart(
        "Sample Pie Chart",
        data,
        true, // legend?
        true, // tooltips?
        true // URLs?
);
*/

CategoryDataset dataset = createDataset();

JFreeChart chart1 = ChartFactory.createLineChart(
        "Métodos Hash",
        "Fator de carga",
        "Média de acessos",
        dataset,
        PlotOrientation.VERTICAL,
        true, // include legend
        true, // tooltips
        false // urls
        );

ChartFrame frame = new ChartFrame("Nome da janela", chart1);
frame.pack();
frame.setVisible(true);



}


}